package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 宣传素材的相关枚举
 */
public class MaterialConstant {


    /**
     * 审核状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum StateEnum implements IntegerEnum<Integer> {
        //状态 0=待发布 1=发布 2=下架
        WAIT(0, "待发布"),
        RELEASE(1, "发布"),
        OFFLINE(2, "下架"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        StateEnum(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static StateEnum getByCode(int code) {
            for (StateEnum value : StateEnum.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 类型枚举
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum TypeEnum implements IntegerEnum<Integer> {
        //状态 0=图片 1=视频 2=音频
        PIC(0, "图片"),
        VIDEO(1, "视频"),
        AUDIO(2, "音频");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        TypeEnum(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static TypeEnum getByCode(int code) {
            for (TypeEnum value : TypeEnum.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }
}
